//
//  CustomTabBarView.m
//  WeChatHelper
//
//  Created by Mac on 14-3-26.
//  Copyright (c) 2014年 bang yi bang. All rights reserved.
//
#define kUI_SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define kUI_SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
#import "CustomTabBarView.h"
#import "UIView+ViewFrameGeometry.h"
@implementation CustomTabBarView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        self.width=kUI_SCREEN_WIDTH;

        
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        
       self.width=kUI_SCREEN_WIDTH;
        
    }
    return self;


}
-(id)init
{
    if (self=[super init]) {
        
        self.width=kUI_SCREEN_WIDTH;
    }
    return self;
}



-(void)initView
{

    [self changAction:0];


    
    
}

        
  
    
    
-(void)selectItem:(NSInteger)num{
   
    [self buttonWasSelected:num];
    
    
}





- (IBAction)changAction:(UIButton *)sender
{
    
       NSLog(@"000000");
    switch (sender.tag) {
        case 0:
      
            [self.delegate buttonWasSelected:0];
            [self buttonWasSelected:0];
          
            break;
        case 1:

            [self.delegate buttonWasSelected:1];
            [self buttonWasSelected:1];
            
            break;
        case 2:

            [self.delegate buttonWasSelected:2];
            [self buttonWasSelected:2];
            break;
            
        default:
            break;
    }

}

- (void)buttonWasSelected:(NSInteger)index
{
    
    
    

    switch (index) {
        case 0:{
            self.msgBt.selected=NO;
            self.rangBt.selected=NO;
            self.MeBt.selected=NO;
        
            
            [UIView transitionWithView:self.msgBt
                              duration:0.5
                               options: UIViewAnimationOptionTransitionFlipFromLeft
                            animations:^{
            [self.msgBt setImage:[UIImage imageNamed:@"icons00"] forState:UIControlStateNormal];
                            }
                            completion:nil];
            

            [self.rangBt setImage:[UIImage imageNamed:@"dc-1"] forState:UIControlStateNormal];
            [self.MeBt setImage:[UIImage imageNamed:@"gr-1"] forState:UIControlStateNormal];
            [self.msgBt setUserInteractionEnabled:YES];
            [self.rangBt setUserInteractionEnabled:YES];
            [self.MeBt setUserInteractionEnabled:YES];
        


        }
            break;
        case 1:
            self.msgBt.selected=NO;
            self.rangBt.selected=YES;
            self.MeBt.selected=NO;
        
        
            [self.msgBt setImage:[UIImage imageNamed:@"icon01"] forState:UIControlStateNormal];
            [self.rangBt setImage:[UIImage imageNamed:@"dc-2"] forState:UIControlStateSelected];
            [self.MeBt setImage:[UIImage imageNamed:@"gr-1"] forState:UIControlStateNormal];
        
        
            [self.msgBt setUserInteractionEnabled:YES];
            [self.rangBt setUserInteractionEnabled:NO];
            [self.MeBt setUserInteractionEnabled:YES];
        
            break;
        case 2:
            self.msgBt.selected=NO;
            self.rangBt.selected=NO;
            self.MeBt.selected=YES;
            
            
            [self.msgBt setImage:[UIImage imageNamed:@"icon01"] forState:UIControlStateNormal];
            [self.rangBt setImage:[UIImage imageNamed:@"dc-1"] forState:UIControlStateNormal];
            [self.MeBt setImage:[UIImage imageNamed:@"gr-2"] forState:UIControlStateSelected];
        
            [self.msgBt setUserInteractionEnabled:YES];
            [self.rangBt setUserInteractionEnabled:YES];
            [self.MeBt setUserInteractionEnabled:NO];
            break;
            
        default:
            break;
    }





}




@end
